<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use app\index\model\Article as ArticleModel;
use app\index\model\Messages as MessagesModel;
use app\index\model\SiftArt;

class Article extends Typez
{
    // 显示文章具体内容和详情
    public function detail(){
        $id = input('id');
        $article = new ArticleModel();
        $messages = new MessagesModel();
        $articleres = $article->art_detail($id);
        $mess = $messages->get_messages($id);
        $this->assign(array(
            'artres' => $articleres,
            'mess' => $mess
        ));
        return view('article/article');
    }

    public function zan(){
        $id = input('id');
        dump($id);
        exit();
        $res = ArticleModel::get(['id' => $id]);
        $res->zan = $res->zan + 1;
        if (!$res->save()){
            return json(['code' => 1, 'msg' => '失败']);
        }
        return json(['code' => 0, 'msg' => '成功']);
    }

    public function sift(){
        $id = input('id');
        $res = SiftArt::get(['id' => $id]);
        $this->assign('sift_art', $res);
        return view();
    }

}
